const formData = (dataArray: string[]) => {
    // 转换格式
    return dataArray.join('-')
}

const formatExpirationDate = (dateString: string): string => {
    // 创建Date对象
    const date: Date = new Date(dateString);
    // 获取年、月、日
    const year: number = date.getUTCFullYear();
    const month: string = (date.getUTCMonth() + 1).toString().padStart(2, '0'); // 月份(索引)是从0开始的
    const day: string = date.getUTCDate().toString().padStart(2, '0');
    // 格式化年月日
    return `${year}-${month}-${day}`;
}

const formatDateArray = (dateString: string): string[] => {
    // 创建Date对象
    const date: Date = new Date(dateString);
    // 获取年、月、日
    const year: string = date.getUTCFullYear().toString();
    const month: string = (date.getUTCMonth() + 1).toString().padStart(2, '0'); // 月份(索引)是从0开始的
    const day: string = date.getUTCDate().toString().padStart(2, '0');
    // 返回dataArray对象
    return [year, month, day]
}

export {formData, formatExpirationDate, formatDateArray}
